import EnumData from "../../Enum/EnumData";
import { utils } from "../../utils/CommonUtil";

export default class BasePanel extends Laya.Sprite {
    protected m_fui: fairygui.GComponent;
    public m_nameID: EnumData.EnumPanelType;
    protected mowner:Laya.Sprite;
    constructor() {
        super();
        // new Laya.Sprite();
        this.m_fui = null;
    }

    protected RemoveAllEvents() {

    }

    public Hide() {
        this.m_fui.visible = false;
    }

    public Show() {
        if (!this.m_fui) return;
        this.m_fui.visible = true;

        //适配
        let bg =this.m_fui.getChild("bg");
        if(bg){
            utils.CommonUtils.adaptSprite(bg.asImage)
        }
        let contentGroup = this.m_fui.getChild("contentGroup");
        if(this.m_fui.getChild("contentGroup")){
            let viewGroup = contentGroup.asGroup;
            utils.CommonUtils.ajustUiY(viewGroup);
        }
    }

    public Close(bRemove: boolean = true, id: EnumData.EnumPanelType = this.m_nameID) {
        window.gameFacade.SceneMng.RemoveFUI(this.m_fui);
        window.gameFacade.SceneMng.destroy(id);
        this.RemoveAllEvents();
    }
}